package guiCode;

import gui.TeacherMainMenuGUI;
import gui.assignmentsGUI;
import java.sql.SQLException;

import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;

import teacher.getassignment;

import basic.ClientConsole;

import com.sun.rowset.CachedRowSetImpl;

import flexibility.CachedRowSetTableModel;
import flexibility.userData;

import com.sun.rowset.CachedRowSetImpl;

public class assignmentscode {
	private assignmentsGUI asg;
	public userData T_Data = new userData();
	public TeacherMainMenuGUI tmm ;
	public ClientConsole teacherConnection=TeacherMainMenuCode.getTeacherConnection();
	public CachedRowSetImpl rs;
	int myID=TeacherMainMenuCode.getMyID();
	private CachedRowSetTableModel data;
	

public CachedRowSetImpl getassignment(String s1,String s3,String s4) throws SQLException{
	getassignment gas = new getassignment();
	rs=gas.getassignments(teacherConnection, rs, T_Data, myID,s1,s3,s4);
	//System.out.println(rs.getString(1));
	return rs;
}
	
	
	public void update(assignmentsGUI as, CachedRowSetImpl crs) {
		JTableHeader tableHeader=new JTableHeader();
		
		
		try {
			as.table_1.setModel(data = new CachedRowSetTableModel(crs));
			DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
			centerRenderer.setHorizontalAlignment(JLabel.CENTER);
			for (int i = 0; i < as.table_1.getColumnCount(); i++)
				as.table_1.getColumnModel().getColumn(i)
						.setCellRenderer(centerRenderer);
			as.table_1.setEnabled(true);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
